/**
 *查找最长的子串
 *
 * @param {String} s1
 * @param {String} s2
 * @returns {String}
 */
function findMaxSubStr(s1, s2) {
    var str = "",
        L1 = s1.length,
        L2 = s2.length;
    if (L1 > L2) {
        var s3 = s1;
        s1 = s2;
        s2 = s3;
        s3 = null;
        L1 = s2.length;
        L2 = s1.length;
    }
    for (var i = L1; i > 0; i--) {
        for (var j = 0; j <= L2 - i && j < L1; j++) {
            str = s1.substr(j, i);
            if (s2.indexOf(str) >= 0) {
                return str;
            }
        }
    }
    return "";
}
var res=findMaxSubStr("fecthcommStr.js","fecthcommStr.js11111111ecthcommStr.");
console.log(res);